<template>
  <div class="c-p">
    <pay-password v-show="showPassword" :price="payMoney" @hidePwd='hidePwd' @confirmPwd='confirmPwd'></pay-password>
    <div>
      <div class="c-ph24 c-flex-row bgTop theme-bg c-aligni-center">
        <div class="c-pl24 c-flex-grow1 c-w0 c-aligni-center">
          <!-- 预售尾款超时未支付且尾款未支付 => 已关闭  -->
          <div class="c-fs26 c-fc-white c-fw-b">{{balanceOrderInfo && balanceOrderInfo.finalBalanceTimeStatus == 2 && balanceOrderInfo.finalBalanceStatus == 0 ? '已关闭' : balanceOrderInfo && balanceOrderInfo.finalBalanceStatus == 0 && status == 1 && balanceOrderInfo.finalBalanceTimeStatus != 2 ? '等待支付尾款' : mapStatus[status]}}</div>
        </div>
        <span v-if="collageInfo.groupStatus == 1" class="c-fs22 c-fc-white">拼团成功</span>
        <span v-if="collageInfo && status == 1 && collageInfo.groupStatus == 2" class="c-fs26 c-fc-white">拼购中不可取消订单</span>
        <span class="c-fs22 c-fc-white" v-if="[-2,-3,-5].includes(status)">{{closeMap[status]}}</span>
        <span class="c-fs22 c-fc-white" v-if="status == 0 && formTime">剩{{formTime}}自动关闭订单</span>
        <span class="c-fs22 c-fc-white" v-if="status == 2 && formTime">剩余{{formTime}}自动完成交易</span>
      </div>
      <div class="c-w100">
        <div class="c-bg-white c-flex-row c-aligni-center c-justify-sb c-ph24 c-pv30 c-mb12" key="" v-if="[1,2,3,5,6].includes(status) && showWayBill">
          <i class="iconfont theme-fc c-fs56" v-if="isSplitPackage == 1 && packageNum > 1">&#xe641;</i>
          <div class="c-fs22 c-lh28 c-fc-sblack c-flex-row c-aligni-center" v-if="isSplitPackage == 1 && packageNum > 1">
            该订单已拆分{{packageNum}}个包裹发出，点击查看物流详情
          </div>
          <div class="c-flex-row c-aligni-center" v-if="(deliverType == 1 && (wayBill && wayBill.shipName && wayBill.shipNo && packageNum <= 1)) || (deliverType == 3 && (isSplitPackage == -1 || (isSplitPackage == 1 && packageNum == 1)))">
            <i class="iconfont theme-fc c-fs56">&#xe641;</i>
            <div v-if="deliverType == 1 && (wayBill && wayBill.shipName && wayBill.shipNo && packageNum <= 1)" class="c-ww500">
              <template v-if="traces">
                <div class="c-fs24 c-lh34 c-fc-xblack c-ml20">
                  {{expressStateMap[state]}}
                </div>
                <div class="c-mt10 c-fs22 c-lh28 c-fc-sblack c-ml20 c-text-ellipsis2">
                  {{traces.AcceptStation}}
                </div>
              </template>
              <template v-else>
                <div class="c-fs24 c-lh34 c-fc-xblack c-ml20">
                  {{wayBill.shipName}}
                </div>
                <div class="c-mt10 c-fs22 c-lh28 c-fc-sblack c-flex-row c-flexw-wrap c-aligni-center c-ml20">
                  运单编号：<span>{{wayBill.shipNo}}</span><div class="c-fs18 c-lh26 c-fc-xblack c-pv6 c-ph18 c-br18 c-bg-f2 c-ml20" @click="copyText(wayBill.shipNo)">复制</div>
                </div>
              </template>
            </div>
            <div v-if="deliverType == 3 && (isSplitPackage == -1 || (isSplitPackage == 1 && packageNum == 1))" class="c-fs24 c-lh34 c-fc-xblack c-ml20">无需物流</div>
          </div>
          <i class="iconfont c-fc-sblack c-fs22" v-if="(!(deliverType == 3 && (isSplitPackage == -1 || (isSplitPackage == 1 && packageNum == 1)))) || traces" @click="goAddressDetail">&#xe908;</i>
        </div>
        <div class="c-bg-white c-flex-row c-aligni-center c-ph24 c-pv30" v-if="shopList && shopList.length > 0 && [0,1,2,3,5,6].includes(status) && deliverType != 2">
          <i class="iconfont theme-fc c-fs56 icon-dizhi"></i>
          <div class="c-ml20 c-flex-grow1 c-w0">
            <template v-if="fromApp == 10">
              <div class="c-fs24 c-lh34 c-fc-xblack">{{addressInfo.mobile}}</div>
            </template>
            <template v-else>
              <div class="c-fs24 c-lh34 c-fc-xblack">
                {{addressInfo.name}}<span class="c-ml20">{{addressInfo.mobile}}</span>
              </div>
              <div class="c-mt10 c-fs22 c-lh28 c-fc-sblack c-flex-row c-aligni-center">地址：{{addressInfo.address}}</div>
            </template>
          </div>
          <div class="c-flex-row c-flex-center iconfont icon-bianji2 c-fc-sblack c-fs-28" v-if="(status == 0 || (status == 1 && isSendSomeGoods == 0)) && shopList[0] && shopList[0].updateAddressTime == null && shopList[0].deliverType != 2" @click="handleClickAddress()"></div>
        </div>
        <!-- 等待支付尾款 超时未支付定金 不展示自提信息 -->
        <div class="c-bg-white c-flex-column c-justify-sb c-ph24 c-pv24" v-if="deliverType == 2 && !(balanceOrderInfo && balanceOrderInfo.finalBalanceStatus == 0 && ((status == 1 && balanceOrderInfo.finalBalanceTimeStatus != 2) || (balanceOrderInfo.finalBalanceTimeStatus == 2)))">
          <div class="c-flex-row c-justify-sb c-alignc-center">
            <div class="c-fs24 c-lh34 c-fc-xblack c-mb20 c-text-ellipsis1 c-fw-b">{{offline.modName}}</div>
            <div class="c-flex-row c-alignc-center">
              <span class="iconfont c-fs30 theme-fc c-pr24 c-bd-r1 c-hh40" @click="getLocation">&#xe8fe;</span>
              <a class="iconfont c-fs30 icon-phone theme-fc c-pl24 c-hh40" :href="'tel:'+offline.contactMobile"></a>
            </div>
          </div>
          <div class="c-fs22 c-lh28 c-mb20 c-flex-row c-aligni-start">
            <span class="c-fc-sblack c-ww112">提货地址：</span><span class="c-fc-xblack c-flex-grow1 c-w0 c-text-ellipsis2">{{offline.address}}</span>
          </div>
          <div class="c-fs22 c-lh28 c-mb20 c-flex-row c-aligni-center">
            <span class="c-fc-sblack c-ww112">营业时间：</span>
            <div class="c-fc-sblack c-flex-grow1 c-text-ellipsis2 c-flex-row c-aligni-center">
              <span class="c-mr4 c-fc-xblack">{{offline.openDate}}</span>
              <span class="c-fc-xblack">{{showCycletime(offline.openStartAt, offline.openEndAt)}}</span>
            </div>
          </div>
          <div class="c-fs22 c-lh28 c-flex-row c-aligni-center c-pb20 c-bd-b1">
            <span class="c-fc-sblack c-ww112">联系电话：</span><span class="c-fc-xblack c-flex-grow1 c-text-ellipsis2">{{offline.contactMobile}}</span>
          </div>
          <div class="c-fs24 c-lh34 c-fc-xblack c-mb20 c-mt20 c-fw-b" v-if="status!=0 && deliverNo != ''">提货码：{{deliverNo}}</div>
          <div class="c-fs22 c-lh28 c-flex-row c-aligni-center c-fc-sblack">
            <span>提货人：</span><span class="c-fc-xblack c-flex-grow1 c-text-ellipsis2">{{addressInfo.name}} {{addressInfo.mobile}}</span>
          </div>
        </div>
      </div>
    </div>

    <section class="c-mt12 c-ph24 c-bg-white" v-if="collageInfo && [1,2].includes(collageInfo.groupStatus)">
      <div @click="goInvite" class="c-flex-row c-aligni-center c-justify-sb c-pv24 c-bd-b1" v-if="collageInfo.groupStatus == 2">
        <div class="c-flex-row c-aligni-center c-justify-sb c-fc-xblack">
          <i class="iconfont c-fs22 c-fc-xblack">&#xe6aa;</i>
          <span class="c-fs22 c-ml10">[拼团中]还差<span class="theme-fc">{{collageInfo.lastPeopleNum}}人</span>拼成，剩<cj-clocker :time="collageInfo.teamList[0].endTime" format="%D天%H时%M分%S秒" @on-finish="finishCollage"></cj-clocker>结束</span>
        </div>
        <span class="iconfont c-fs18 c-fc-gray">&#xe60e;</span>
      </div>
      <div v-if="collageInfo.groupStatus == 1" class="c-textAlign-c c-fs28 c-fc-xblack c-pv24">
        <span class="icon iconfont c-fs30 c-fc-green c-mr16">&#xe6eb;</span>恭喜您，拼团成功
      </div>
      <div class="c-pv30 c-flex-row c-aligni-center c-justify-sb">
        <div class="c-flex-grow1 c-w0 c-flex-row c-justify-center">
          <div class="c-p c-ml20 c-flex-shrink0" v-for="(item, index) in collageInfo.teamList" :key="index">
            <img :src="$addXossFilter(item.headimgurl, require('../../../assets/defult_head.png'))" class="c-ww80 c-hh80 c-br50" />
            <div v-if="item.type == 1" class="c-fs18 c-fc-white theme-bg-gradient c-textAlign-c c-pa c-p-t0 c-p-r0 c-pv4 c-ph6 c-br-tr20 c-br-bl20">团长</div>
          </div>
          <div @click="showAllTeam" class="c-ww80 c-flex-shrink0 c-hh80 c-br50 c-bd-d1 c-bg-fa c-textAlign-c c-lh80 c-ml20 c-fc-gray">+</div>
        </div>
      </div>
    </section>

    <section class="c-mt12 c-bg-white c-ph24">
      <div @click="clickGoShop(item.mgId)" :class="index != 0 ? 'c-bd-t1-f6':''" v-for="(item,index) in shopList" :key="index">
        <div class="c-flex-row c-pv20">
          <div class="c-ww160 c-hh160 c-text-hidden">
            <img class="c-w100 c-br20 c-h c-object-fit-cover" :src="$addXossFilter(item.avatar)" alt="" />
          </div>
          <div class="c-pl20 c-flex-grow1 c-w0 c-pt6 c-flex-column c-justify-sb">
            <div class="c-flex-row">
              <div class="c-maxw316">
                <div class="c-fs22 c-fw-b c-text-ellipsis1 c-lh32"><span v-if="item.isGift && item.isGift == 1" class="c-fs20 theme-bd1 theme-fc c-ph4 c-pv2 c-br4 c-mr10">赠品</span>{{item.goodsName}}</div>
                <div class="c-fs20 c-fc-gray c-mt20" v-if="item.subSpecs">
                  <collapse :default-height="52">
                    <div>规格：{{item.subSpecs}}</div>
                  </collapse>
                </div>
              </div>
              <div class="c-w0 c-flex-grow1 c-textAlign-r">
                <div class="c-fs24 c-fc-xblack">{{'￥' | iosPriceFilter}}{{item.type == 2 ? (giftCardPay ? item.price : item.amount) : item.price}}</div>
                <div class="c-fs22 c-fc-gray c-mt5">x {{item.quantity}}</div>
              </div>
            </div>
            <div class="c-flex-row c-aligni-center c-justify-sb" v-if="item.valuationMethod && item.valuationMethod == 2 && item.freightMode == 1 && !onlyValuationMethod">
              <div class="c-fs24 c-fc-xblack">运费</div><div class="c-fs22 c-fc-gray">到付</div>
            </div>
            <div class="c-flex-row c-aligni-center c-justify-end">
              <span class="theme-fc c-fs22" :class="item.isRefund == 1 ? 'c-w0 c-flex-grow1' : ''" v-if="status == 1 && item.deliverStatus == 2 && shopList && (shopList.length != packageNum)">已发货</span>
              <span class="theme-fc c-fs22" v-if="item.isRefund == 1 || item.status == 5">退款成功</span>
            </div>
          </div>
        </div>
        <div v-if="(((item.afterStatus == -1) && (fromApp != 10) && (item.enableAfterSale == 1)) || (item.afterStatus == 1)) && (balanceOrderInfo == null || (balanceOrderInfo && !!balanceOrderInfo.finalBalanceStatus && balanceOrderInfo.finalBalanceStatus == 1)) && !(item.afterStatus == -1 && orderDetail.enableApplyRefund == 0)" class="c-flex-row c-justify-end c-pb20">
          <div class="c-fs22 c-ww130 c-h c-flex-row c-flex-center c-fc-xblack c-bd1-ccc c-br25 c-ml24 c-pv10" @click.stop="goApplyRefund(item)">{{item.afterStatus == -1 ? '申请退款' : (item.refundType == 1 ? '退款中' : '退货中')}}</div>
        </div>
        <!-- 关联售卖列表 -->
        <div v-if="item.relData && item.relData.length > 0" class="c-bd-t1-f6">
          <mall-package-list :relData="item.relData" :templateStyle="3"></mall-package-list>
        </div>
      </div>
      <div v-if="isShopListType && shopList[0]" class="c-bd-t1-f6">
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20" :class="shopList.length > 0 && shopList[0].invoiceTitle ? '' : 'c-pt30'">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">商品总价</span>
          <span class="c-fc-xblack">{{'￥' | iosPriceFilter}}{{goodsTotalPrice}}</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20" v-if="collageInfo || shopList[0].collageId">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">拼团价</span>
          <span class="c-fc-xblack">{{'￥' | iosPriceFilter}}{{shopList[0].amount}}</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20" v-if="shopList && shopList[0] && shopList[0].type == 512 && totalHadBargainPrice > 0">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">砍价优惠</span>
          <span class="c-fc-xblack">-{{'￥' | iosPriceFilter}}{{totalHadBargainPrice}}</span>
        </div>
        <!-- fromApp 16 线下支付 -->
        <div v-if="!(Number(chainDiscountMoney) > 0 && isChainOrder) && hasVipDiscount && !collageInfo && !(shopList[0] && shopList[0].collageId) && !(shopList && shopList[0] && shopList[0].type == 512) && balanceOrderInfo == null && fromApp != 16" class="c-flex-row c-pb24 c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">会员抵扣</span>
          <span class="c-fc-xblack">-{{'￥' | iosPriceFilter}}{{vipDisAmount}}</span>
        </div>
        <div v-if="Number(chainDiscountMoney) > 0 && isChainOrder" class="c-flex-row c-pb24 c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">{{isReorder == 1 ? '复购' : '购买'}}优惠</span>
          <span class="c-fc-xblack">-{{'￥' | iosPriceFilter}}{{chainDiscountMoney}}</span>
        </div>
        <div v-if="deductedMoney * 1 > 0" class="c-flex-row c-pb24 c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">{{ customPointName}}抵扣</span>
          <span class="c-fc-xblack">-{{'￥' | iosPriceFilter}}{{deductedMoney}}</span>
        </div>
        <div v-if="deductedCouponMoney * 1 > 0 " class="c-flex-row c-pb24 c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">优惠券抵扣</span>
          <span class="c-fc-xblack">-{{'￥' | iosPriceFilter}}{{(deductedCouponMoney * 1).toFixed(2)}}</span>
        </div>
        <div v-if="favourablePrice * 1 != 0" class="c-flex-row c-pb24 c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">商家改价</span>
          <span class="c-fc-xblack">{{favourablePrice > 0 ? '+' : '-'}}{{'￥' | iosPriceFilter}}{{(favourablePrice).toString().replace(/-/g,'')}}</span>
        </div>
        <div v-if="cashBackAmount * 1 > 0" class="c-flex-row c-pb24 c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">满减送</span>
          <span class="c-fc-xblack c-flex-row c-aligni-center" @click="showCashBack = true">-{{'￥' | iosPriceFilter}}{{cashBackAmount}}<span class="iconfont icon-shuoming1 c-fs28 c-fc-sgray c-ml12"></span></span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20" v-if="(postage * 1 > 0) || (onlyValuationMethod)">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">运费</span>
          <span class="c-fc-xblack" v-if="!onlyValuationMethod && postage * 1 > 0">{{'￥' | iosPriceFilter}}{{postage}}</span>
          <span class="c-fc-xblack" v-else>到付</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20" v-if="giftCardPay > 0">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">虚拟币抵扣</span>
          <span class="c-fc-xblack">{{giftCardPay}}币</span>
          <!-- <span class="c-fc-xblack">{{'￥' | iosPriceFilter}}{{Number(goodsTotalPrice)+Number(postage)}}{{' (' + giftCardPay + '币)'}}</span> -->
        </div>
      </div>
      <!-- 礼包或者兑换券兑换的商品，需展示运费 -->
      <div v-if="shopList[0] && (shopList[0].type == 1024 || shopList[0].type == 4096)" class="c-bd-t1-f6">
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20 c-pt30">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">商品总价</span>
          <span class="c-fc-xblack">{{'￥' | iosPriceFilter}}{{goodsTotalPrice}}</span>
        </div>
        <div class="c-flex-row c-pb24 c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">{{shopList[0].type == 4096 ? '兑换券抵扣' : '礼包兑换抵扣'}}</span>
          <span class="c-fc-xblack">-{{'￥' | iosPriceFilter}}{{goodsTotalPrice}}</span>
        </div>
        <div v-if="(postage * 1 > 0) || (onlyValuationMethod)" class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">运费</span>
          <span class="c-fc-xblack" v-if="!onlyValuationMethod && postage * 1 > 0">{{'￥' | iosPriceFilter}}{{postage}}</span>
          <span class="c-fc-xblack" v-else>到付</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center c-fs20" v-if="giftCardPay > 0">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">虚拟币抵扣</span>
          <span class="c-fc-xblack">{{giftCardPay}}币</span>
          <!-- <span class="c-fc-xblack">{{'￥' | iosPriceFilter}}{{Number(goodsTotalPrice)+Number(postage)}}{{' (' + giftCardPay + '币)'}}</span> -->
        </div>
      </div>
      <div class="c-flex-row c-aligni-center c-justify-end c-fs20 c-pb30" :class="{'c-pt30': shopList[0] && shopList[0].type == 16}" v-if="fromApp != 16">
        <div v-if="status == 1 || status == 2 || status == 3">{{orderDetail.type == 2048 && balanceOrderInfo && balanceOrderInfo.finalBalanceStatus == 0 && status > 0 ? '已付定金' : '实付款'}}：</div>
        <div v-else>需付{{status == 0 && balanceOrderInfo ? '定金' : '款'}}：</div>
        <div class="theme-fc c-fw400 c-flex-row c-aligni-center">{{'￥' | iosPriceFilter}}<div v-html="filterMoney"></div></div>
      </div>
      <div class="c-pb30 c-flex-row c-aligni-center c-justify-end c-fs20" v-else>
        <div>线下付款：</div>
        <div class="theme-fc c-fw400 c-flex-row c-aligni-center" v-if="orderDetail.offlinePayMoney">{{'￥' | iosPriceFilter}}<div><span class="c-fs28">{{orderDetail.offlinePayMoney.split(".")[0]}}</span>.<span>{{orderDetail.offlinePayMoney.split(".")[1]}}</span></div></div>
      </div>
      <!-- 联系客服 -->
      <custom-service-tmp :position="2"></custom-service-tmp>
    </section>
    <section class="c-mt12 c-bg-white c-ph24 c-pv24 c-flex-row c-aligni-center c-justify-center" v-if="payAward != null">
      <div class="c-w100" @click="handleClickpayAward()">
        <!-- awardType:1优惠卷2商城3参与活动 -->
        <template v-if="payAward.awardType == 1">
          <img
            src="https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/payPolitely/coupon.png"
            alt=""
          >
        </template>
        <template v-else-if="payAward.awardType == 2">
          <img
            src="https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/payPolitely/gift.png"
            alt=""
          >
        </template>
        <template v-else>
          <img
            src="https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/payPolitely/activity.png"
            alt=""
          >
        </template>
      </div>
    </section>
    <section class="c-mt12 c-bg-white c-flex-column c-ph24 c-fs20 c-fc-sblack" v-if="shopList && shopList.length > 0">
      <div v-if="shopList.length > 0" class="c-pt34 c-pb28 c-flex-row c-justify-sb c-aligni-center">
        <span class="c-flex-grow1 c-w0 c-fc-sblack">订单编号</span>
        <div class="c-fc-xblack">{{shopList[0].orderNo}}<span class="c-ph20 c-pv8 c-fs18 c-fc-xblack c-ml20 c-br20 c-bg-f2" @click="copyText(shopList[0].orderNo)">复制</span></div>
      </div>
      <template v-if="isShopListType && shopList[0]">
        <div v-if="shopList.length > 0 && shopList[0].invoiceTitle" class="c-pb24">
          <div class="c-flex-row c-justify-sb c-aligni-center"><span>发票类型</span> <span class="c-fc-xblack">纸质发票</span></div>
          <div class="c-pt24 c-flex-row c-justify-sb c-aligni-center"><span>发票抬头：</span> <span class="c-fc-xblack">{{shopList[0].invoiceTitle}}</span></div>
          <div class="c-pt24 c-flex-row c-justify-sb c-aligni-center"><span>{{shopList[0].invoiceCode ? '公司名称' : '个人名称'}}：</span> <span class="c-fc-xblack">{{shopList[0].invoiceMsg}}</span></div>
          <div class="c-pt24 c-flex-row c-justify-sb c-aligni-center" v-if="shopList[0].invoiceCode"><span>纳税识别码：</span> <span class="c-fc-xblack">{{shopList[0].invoiceCode}}</span></div>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center" v-if="shopList[0].mail">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">邮箱</span>
          <span class="c-fc-xblack">{{shopList[0].mail}}</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center" v-if="orderDetail.addPoint > 0">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">获得{{ customPointName }}</span>
          <span class="c-fc-xblack">{{orderDetail.addPoint}}{{customPointName}}</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center" v-if="shopList[0].createdAt">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">创建时间</span>
          <span class="c-fc-xblack">{{shopList[0].createdAt}}</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center" v-if="shopList[0].payAt">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">付款时间</span>
          <span class="c-fc-xblack">{{shopList[0].payAt}}</span>
        </div>
        <div class="c-pb24 c-flex-row c-justify-sb c-aligni-center" v-if="orderDetail.msg">
          <span class="c-flex-grow1 c-w0 c-fc-sblack">买家留言</span>
          <span class="c-fc-xblack c-maxw456 c-textAlign-r">{{orderDetail.msg}}</span>
        </div>
      </template>
    </section>
    <section class="c-pv20 c-flex-row c-aligni-center c-flexw-wrap c-fs20 theme-fc" v-if="protocolInfo">
      <span class="c-fc-gray c-pl20">已阅读并同意</span>
      <span @click.stop="clickProtocol(item)" v-for="(item, index) in protocolInfo" :key="index">《{{item.name}}》</span>
    </section>
    <div class="c-bg-white c-pv16 c-ph24 c-flex-row c-justify-end order-fotter" v-if="status == 3 && [1,2].includes(commentStatus)">
      <div class="c-fs22 c-lh32 c-pv8 c-ph24 c-br24" :class="hasComment == 2 ? 'c-bd1-ccc c-fc-xblack' : 'theme-bd1 theme-fc'" @click="goComments(commentStatus)">{{commentStatus == 2 ? '评价' : '查看评价'}}</div>
    </div>
    <footer v-if="[-5,-3,-2,-1,0,2].includes(status) ||
              (status == 1 && collageInfo && collageInfo.groupStatus == 2) ||
              ((status == 0 || (status == 1 && isSendSomeGoods == 0)) && shopList[0] && shopList[0].updateAddressTime == null && shopList[0].deliverType != 2 && (!balanceOrderInfo || (balanceOrderInfo && balanceOrderInfo.finalBalanceStatus == 1))) ||
              orderDetail.isRefundLog == 1 ||
              (balanceOrderInfo && balanceOrderInfo.finalBalanceStatus == 0 && [0, 1, 2].includes(balanceOrderInfo.finalBalanceTimeStatus)) ||
              shopList.length > 0 && !shopList[0].invoiceTitle"
      class="order-fotter c-bg-white c-hh80 c-flex-row c-flex c-justify-end c-ph24 c-pv12">
      <template v-if="balanceOrderInfo && balanceOrderInfo.finalBalanceStatus == 0">
        <div class="c-pv30 c-flex-row c-aligni-center c-justify-sb c-w100 c-fs24" v-if="[0, 1].includes(balanceOrderInfo.finalBalanceTimeStatus) && status == 1">
          {{balanceOrderInfo.finalBalanceTimeStatus == 0 ? '' : '请在'}}{{getLeaveTime}}
        </div>
        <div class="c-br25 c-fs22 c-h c-ml24 c-hh52 c-lh52 c-textAlign-c c-ww160" v-if="[0, 1].includes(balanceOrderInfo.finalBalanceTimeStatus) && status == 1" :class="balanceOrderInfo.finalBalanceTimeStatus == 1 ? 'theme-bd1 theme-fc' : 'c-bd1-ccc c-fc-sgray'" @click.stop="clickPayOrder">{{status != 0 ? '支付尾款' : '继续支付'}}</div>
        <div class="c-pv30 c-flex-row c-aligni-center c-fs24 c-flex-grow1" v-if="balanceOrderInfo.finalBalanceTimeStatus == 2 && status >= 0">
          已结束，未在指定时间内支付尾款
        </div>
        <div class="c-fs22 c-hh52 c-lh52 c-textAlign-c c-ml12 c-fc-xblack c-bd1-ccc c-ww116 c-br25" v-if="balanceOrderInfo.finalBalanceTimeStatus == 2" @click.stop="goApplyRefund()">退定金</div>
      </template>
      <div v-if="status > 0 && orderDetail.isInvoice == 1 && shopList.length > 0 && !shopList[0].invoiceTitle && shopList[0].isInvoice == -1" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center c-fc-xblack c-bd1-ccc c-br25 c-ml24" @click="clickShowInvoice">开票</div>
      <div v-if="orderDetail.isRefundLog == 1 && orderDetail.type != 1024" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center c-fc-xblack c-bd1-ccc c-br25 c-ml24" @click="clickRefundList()">售后记录</div>
      <div v-if="(status == 0 || (status == 1 && isSendSomeGoods == 0)) && shopList[0] && shopList[0].updateAddressTime == null && shopList[0].deliverType != 2 && (!balanceOrderInfo || (balanceOrderInfo && balanceOrderInfo.finalBalanceStatus == 1))" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center c-fc-xblack c-bd1-ccc c-br25 c-ml24" @click="handleClickAddress()">修改地址</div>
      <div v-if="status == 0" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center c-fc-xblack c-bd1-ccc c-br25 c-ml24" @click="clickCancelOrder">取消订单</div>
      <div v-if="status == 0" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center theme-bg c-fc-white c-br25 c-ml24" @click="clickSubmitOrder">去支付</div>
      <div v-if="(status == 2 && buyerIsDelayReceive == 0) && deliverType != 2 && fromApp != 10" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center c-fc-xblack c-bd1-ccc c-br25 c-ml24" @click="clickDelayReceiveOrder">延长收货</div>
      <div v-if="status == 2 && fromApp != 10" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center theme-bg c-fc-white c-br25 c-ml24" @click="orderConfirmReceipt">确认收货</div>
      <div v-if="[-1,-2,-3,-5].includes(status) && !(balanceOrderInfo && balanceOrderInfo.finalBalanceTimeStatus == 2)" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center c-fc-white theme-bg c-br25 c-ml24" @click="clickDelectOrder">删除订单</div>
      <div v-if="status == 1 && collageInfo && collageInfo.groupStatus == 2" class="c-fs22 c-ww130 c-h c-flex-row c-flex-center theme-bg c-fc-white c-br25 c-ml24" @click="goInvite">邀请好友</div>
    </footer>
    <div class="c-pf c-p-b0 c-p-l0 c-hh80 c-lh80 c-textAlign-c c-fs24 c-fc-white c-bg-live-orange c-w100 c-fw-b c-pz100" v-if="fromApp == 10">
      处理售后事宜请到微信--视频号---订单那处理
    </div>
    <cj-popup v-model="showAllMerber" class="c-w85 c-br6">
      <div v-if="showAllMerber" class="c-p c-w100 c-ph30 c-pt40 c-pb30 c-flex-column c-aligni-center">
        <div class="c-fs28 c-fc-xblack c-mb20">参与拼团</div>
        <div v-if="collageInfo && collageInfo.groupStatus == 2" class="c-fs22 c-fc-xblack ">还差<span class="theme-fc">{{collageInfo.lastPeopleNum}}人</span>拼成，剩<cj-clocker :time="collageInfo.teamList[0].endTime" format="%D天%H时%M分%S秒"></cj-clocker>结束</div>
        <div class="c-maxh500 c-contexty-scroll c-mt48">
          <div class="c-flex-row c-justify-sa c-mb20" :key="index" v-for="(item, index) in (Math.floor(allTeamList.length/5) + 1)">
            <div v-show="(sindex >= index * 5) && (sindex < (index * 5 + 5))" v-for="(sitem, sindex) in allTeamList" :key="sindex" class="c-hh80 c-ww80 c-br50 c-flex-row c-flex-center c-p">
              <img :src="$addXossFilter(sitem.headimgurl, require('../../../assets/defult_head.png'))" class="c-brp50 c-ww80 c-hh80 c-pa c-p-l0 c-p-t0" alt="">
              <div class="c-pa c-fs18 c-fc-white c-ww50 c-hh26 c-lh28 c-textAlign-c theme-bg c-p-t0 c-p-r0 c-opacity80 c-br-tr16 c-br-bl16">{{sitem.type == 1 ? '团长' : '团员'}}</div>
            </div>
          </div>
        </div>
        <div v-if="collageInfo && collageInfo.groupStatus == 2" @click="goInvite" class="c-ww240 c-hh50 c-br25 theme-bg c-lh54 c-fs22 c-fc-white c-mt32 c-flex-row c-flex-center">邀请好友</div>
      </div>
    </cj-popup>

    <open-modal :openModal='showCashBack' @closeModal='showCashBack = false'>
      <div class="masker-content c-br-tl20 c-br-tr20">
        <div class="c-p">
          <div class="c-w100 c-textAlign-c c-fs28 c-pt24 c-fc-sblack">活动优惠</div>
          <i class="iconfont c-pa c-p-t30 c-p-r24 c-fc-sgray c-fs20 c-bg-f6 c-ww30 c-hh30 c-brp50 c-flex-row c-flex-center" @click="showCashBack = false">&#xe8fd;</i>
          <div class="c-ph24 c-mt80">
            <div class="c-fs22 c-fc-xblack c-mt12 c-flex-row c-aligni-center c-justify-sb c-pb24 c-mb24 c-bd-b1">
              <div class="c-fs22 c-fc-xblack c-flex-row c-aligni-center">
                <span class="c-fc-lorange c-br2 tagBg c-pv2 c-ph4 c-fs18 c-mr12">满减送</span>
                <span v-if="cashTitle && cashTitle.length > 0" class="c-maxw400 c-text-ellipsis1">{{cashTitle}}</span>
              </div>
              <div class="c-fs22 c-fc-xblack">
                <span class="c-fs16">-{{'￥' | iosPriceFilter}}</span>
                <span v-if="cashBackAmount * 1 > 0">{{cashBackAmount}}</span>
              </div>
            </div>
            <div class=" c-flex-row c-aligni-center c-justify-end">
              <div class="c-fs22 c-fc-xblack">
                合计：
                <span class="c-fs16 theme-fc">-{{'￥' | iosPriceFilter}}</span>
                <span class="theme-fc" v-if="cashBackAmount * 1 > 0">{{cashBackAmount}}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </open-modal>
    <open-modal :openModal='showRefundType' @closeModal='showRefundType = false'>
      <div class="masker-content1 c-br-tl20 c-br-tr20">
        <div class="c-p">
          <div class="c-w100 c-textAlign-c c-fs28 c-pt24 c-fc-sblack">选择退款类型</div>
          <i class="iconfont c-pa c-p-t30 c-p-r24 c-fc-sgray c-fs20 c-bg-f6 c-ww30 c-hh30 c-brp50 c-flex-row c-flex-center" @click="showRefundType = false">&#xe8fd;</i>
          <div class="c-ph24 c-mt24">
            <div class="c-pv24 c-bd-b1" @click="clickRefundType(0)">
              <p class="c-fs24 c-fc-xblack c-pb12">仅退款</p>
              <p class="c-fs22 c-fc-gray">没收到货或与商家协商不用退货</p>
            </div>
            <div class="c-pv24" @click="clickRefundType(2)">
              <p class="c-fs24 c-fc-xblack c-pb12">退货退款</p>
              <p class="c-fs22 c-fc-gray">已收到货，需要退货给商家才能退款</p>
            </div>
          </div>
        </div>
      </div>
    </open-modal>

    <!-- 开票 -->
    <invoice-modal :showInvoice="showInvoice" @getInvoice="setInvoice" @clickCloseModal="clickCloseModal"></invoice-modal>
    <!-- 优惠卷 -->
    <coupon-modal v-if="showCouponDialog" adName="恭喜你获得优惠券礼包" :isVoucher="isVoucher" :adCoupon="adCoupon" :isPayAward="isPayAward" :palId="palId" :osId="palId" recordType="-1" :showCouponDialog.sync="showCouponDialog"></coupon-modal>
    <!-- 赠品为知识商品弹窗 -->
    <div class="c-w100 c-h c-pf c-p-t0 c-p-l0 c-p-b0 c-p-r0 c-translucent-balck50 c-pz10" v-show="giftModal" v-if="awardInfo" @click.stop="handleClickCloseModal()">
      <div class="giftDialog c-flex-row c-justify-center">
        <div class="c-fs40 c-fc-reword c-pa c-text-ellipsis1 c-fw600 giftDialog_msg">{{awardInfo.prodType == ckFrom.course ? '恭喜您获得学习权限':'恭喜您获得下方的商品'}}</div>
        <div class="c-pa c-ww240 c-hh160 giftDialog_img">
          <img class="c-m-0auto imgCloseBig c-maxh c-h c-object-fit-c" :src="$addXossFilter(awardInfo.cover)" alt="">
        </div>
        <div class="c-pa c-text-ellipsis1 c-fs24 c-fc-xblack giftDialog_name">{{awardInfo.name}}</div>
        <div class="c-pa giftDialog_btn c-flex-row c-flex-center" @click="handleClickSubmit()">{{awardInfo.prodType == ckFrom.course ? '查看':'立即领取'}}</div>
        <div class="giftDialog_get c-pa c-fs22 c-text-ellipsis1" v-if="awardInfo.prodType == ckFrom.course">您可前往"我的课程"进行查看并学习</div>
      </div>
    </div>
    <pay-template v-if="isShowPay" :ckFrom="ckFrom.shopping" :balance='balance' :totalPrice='payMoney * 1' :enablePayMall="payConf ? (payConf.enablePayMall == 0 ? false : true) : true" :enableWxpay="!!(payConf.enableWxpay == 1)" @clickPayType='clickPayType' :isCanUseGiftCard="isCanUseGiftCard" :coinAmount="coinAmount" :totalCoin="payCoinNum" @closePay="closePay"></pay-template>

  </div>
</template>

<script>
import OpenModal from "@/components/templates/common/openModal.vue";
import PayTemplate from "@/components/templates/common/pay/payTemplate.vue";
import PayPassword from "@/components/templates/common/pay/payPassword.vue";
import couponModal from "@/components/templates/couponModal.vue";
import { utilJs } from "@/utils/common.js";
import { checkEnableModule } from "@/utils/checkEnableModuleUtil.js";
import qr from "@/utils/qr.js";
import mallPackageList from "@/components/templates/shop/mallPackageList.vue";
import collapse from "@/components/templates/common/collapse.vue";
import CustomServiceTmp from '@/components/templates/custService/customServiceTmp.vue';
import InvoiceModal from "@/components/templates/invoiceModal.vue";
import { mapState } from 'vuex';
let goId = "";
let isClick = false;
let isWechatPaying = false;
let timeControl;
let countDownTime = "";
let automaticCancelTime = 0; //未支付自动关闭时间
let automaticRecipientTime = 0; //未收获自动收获时间
let currentDate = 0; //系统时间
let isTest = false; //判断是否时测试平台
let isFromOrderList = false; // 判断是否是商城订单列表页面进入
let isFromAllOrderList = false; // 判断是否是订单整合列表页面进入
let orderType = -1; // 订单列表的type -1全部 0待付款 1待发货 2待收货 3待评价
export default {
  name: "OrderDetail",
  components: {
    PayTemplate,
    PayPassword,
    OpenModal,
    couponModal,
    mallPackageList,
    collapse,
    CustomServiceTmp,
    InvoiceModal
  },
  props: [],
  computed: {
    ...mapState({
      orderList: state => state.oem_store.orderList,
      allOrderList: state => state.oem_store.allOrderList
    }),
    showWayBill () {
      return ((this.deliverType == 1 && (this.wayBill && this.wayBill.shipName && this.wayBill.shipNo && this.packageNum <= 1))
              || (this.isSplitPackage == 1 && this.packageNum > 1)
              || (this.deliverType == 3 && (this.isSplitPackage == -1 || (this.isSplitPackage == 1 && this.packageNum == 1))))
    },
    onlyValuationMethod() {
      let flag = this.shopList.every(item => item.valuationMethod && item.valuationMethod == 2 && item.freightMode == 1);
      return flag
    },
    // 获取尾款支付日期如下： 3月28日 9:30
    getLeaveTime() {
        // 尾款还未开始 尾款支付开始时间+开始支付尾款 尾款开始支付 尾款支付截至时间+前支付尾款
      if (this.balanceOrderInfo == null || this.balanceOrderInfo.leaveEndTime == null || this.balanceOrderInfo.leaveStartTime == null) return
      let leaveEndTime = new Date(this.balanceOrderInfo.leaveEndTime.replace(/-/g, "/"));
      let leaveStartTime = new Date(this.balanceOrderInfo.leaveStartTime.replace(/-/g, "/"));
      leaveEndTime = new Date(leaveEndTime.getTime() + 1000); // 前支付尾款 得加一秒 让展示更严谨
      if (this.balanceOrderInfo.finalBalanceTimeStatus == 0) {
        return `${leaveStartTime.getMonth() + 1}月${leaveStartTime.getDate()}日 ${leaveStartTime.getHours() > 9 ? '' + leaveStartTime.getHours() : '0' + leaveStartTime.getHours()}:${leaveStartTime.getMinutes() > 9 ? '' + leaveStartTime.getMinutes() : '0' + leaveStartTime.getMinutes()}开始支付尾款`
      } else if (this.balanceOrderInfo.finalBalanceTimeStatus == 1) {
        return `${leaveEndTime.getMonth() + 1}月${leaveEndTime.getDate()}日 ${leaveEndTime.getHours() > 9 ? '' + leaveEndTime.getHours() : '0' + leaveEndTime.getHours()}:${leaveEndTime.getMinutes() > 9 ? '' + leaveEndTime.getMinutes() : '0' + leaveEndTime.getMinutes()}前支付尾款`
      }
    },
    // 获取总砍价金额 砍价优惠 = 商品总价 + 邮费 - 现在支付价格
    totalHadBargainPrice() {
      return (this.goodsTotalPrice * 1 + this.postage * 1 - this.shopList[0].payMoney * 1).toFixed(2);
    }
  },
  data() {
    return {
      customPointName: localStorage.getItem("customPointName"),
      theme: localStorage.getItem("colorName") ? localStorage.getItem("colorName") : "mb5_default",
      companyAuth: JSON.parse(localStorage.getItem("companyAuth")),
      showPassword: false, //显示余额支付输入密码弹窗
      isShowPay: false,
      addressInfo: {
        name: "",
        mobile: "",
        address: "",
      },
      postage: '',
      deductedPoints: '',
      deductedMoney: '',
      deductedCouponMoney: 0,
      favourablePrice: 0,
      cashBackAmount: '',
      payMoney: '',
      filterMoney: '',
      status: 1, //订单状态
      mapStatus: {
        '-5': '已关闭',
        "-4": "删除订单",
        "-3": "已关闭",
        "-2": "已关闭",
        "-1": "交易关闭",
        "0": '等待付款',
        "1": '待发货',
        "2": '待收货',
        "3": '完成',
        "5": '已退款',
        "6": '退款失败'
      },
      shopList: [],
      formTime: '',
      hasFlash: false,
      vipType: 1,
      hasVipDiscount: false,
      vipDisAmount: 0,
      collageInfo: "",
      showAllMerber: false,
      allTeamList: [],
      deliverType: 1,
      offline: null,
      deliverNo: null, //自提码
      isShopListType: true,
      commentStatus: 2, // -1评价过被刪除1评价过2未评价
      wayBill: null, //运单信息
      closeMap: { //订单关闭类型
        '-5': '商家取消订单',
        '-3': '超时关闭',
        '-2': '买家取消订单',
      },
      buyerIsDelayReceive: 0, //0不延迟收货 1延迟收货
      guideData: '', //入群引导数据
      packageNum: 0, // 包裹数量
      showCashBack: false, // 满减弹窗
      isSplitPackage: -1, // 是否拆分发货
      isSendSomeGoods: 0, // 是否部分发货
      cashTitle: '', // 参加满减活动标题
      payAward: null, //支付有礼信息
      awardInfo: null,
      palId: '',
      isPayAward: false, //判断当前为支付有礼的优惠卷
      showCouponDialog: false,
      giftModal: false,
      adCoupon: [],
      traces: null, // 物流订单的轨迹最新的一条记录
      expressStateMap: { // 物流状态Map
        '0': '暂无物流信息',
        '1': '已揽收',
        '2': '在途中',
        '3': '已签收',
        '4': '问题件'
      },
      state: 0, // 物流状态
      enableRefund: 0, // 是否可以售后
      orderDetail: {},
      protocolInfo: null, // 支付协议
      isVoucher: false,
      ckFrom: global.ckFrom,
      payConf: null,
      showRefundType: false, // 选择退款类型
      currentGodId: '', // 当前退款商品
      marketStatus: null,
      isCanUseGiftCard: true, // 判断是使用虚拟币支付
      payCoinNum:0, //虚拟币支付金额
      coinAmount:0, //账户虚拟币
      proportion: 0, // 虚拟币兑换率
      giftCardPay: 0, // 使用虚拟币
      fromApp: '',
      isCustServiceOpen: localStorage.getItem("isCustServiceOpen") == 1 ? true : false, // 是否开启小程序客服
      balanceOrderInfo: null, // 预售订单信息
      showInvoice: false,
      isChainOrder: false,
      chainDiscountMoney: 0,
      isReorder: 0
    };
  },
  beforeRouteEnter(to, from, next) {
    if (from.path == '/mall/mallOrder/orderList') {
      isFromOrderList = true;
    } else if (from.path == '/member/myOrder/allOrderList') {
      isFromAllOrderList = true;
    }
    next();
  },
  created() {
    utilJs.appShare(this);
  },

  methods: {
    // 填写开票信息
    setInvoice(data) {
      this.showInvoice = false;
      if (!(data && (data.invoiceName || data.invoiceCode))) return;
      data.goId = goId;
      utilJs.postMethod(
        global.apiurl + "goodsOrders/setInvoice", data, res => {
          this.$showCjToast({
            text: "提交成功",
            type: "success",
          });
          this.getOrderInfo()
        }
      )
    },
    clickCloseModal() {
      this.showInvoice = false;
    },
    clickShowInvoice() {
      this.showInvoice = true;
    },
    clickRefundList() {
      this.$routerGo(this, "push", {
        path: '/member/myRefund/myRefundList',
        query: ({goId: goId})
      })
    },
    handleClickCloseModal() {
      this.giftModal = false;
    },
    clickProtocol(item) {
      this.$routerGo(this, "push", { path: `/homePage/agent/protocolInfo`, query: { protocolId: item.protocolId } });
    },
    // 局部更新订单详情页面数据
    partUpateOrder(operactionInfo) {
      if (operactionInfo == null) {
        return
      }
      if (operactionInfo.operaction == 'editAddress') {
        // 不展示修改地址
        this.setOrderListAttribute(operactionInfo.goId, 'updateAddressTime', 1);
      } else if (operactionInfo.operaction == 'receiveOrder') {
        // 当页面在待收货的tab页面
        if (orderType == 2) {
          this.filterOrderList(operactionInfo.goId);
        } else {
          // 确认收货
          this.setOrderListAttribute(operactionInfo.goId, 'status', 3);
        }
      } else if (operactionInfo.operaction == 'deleteOrder') {
        // 删除订单
        this.filterOrderList(operactionInfo.goId);
      } else if (operactionInfo.operaction == 'cancelOrder') {
        // 当页面在待付款的tab页面
        if (orderType == 0) {
          this.filterOrderList(operactionInfo.goId);
        } else {
          // 取消订单
          this.setOrderListAttribute(operactionInfo.goId, 'status', -5);
        }
      } else if (operactionInfo.operaction == 'payOrder') {
        // 当页面在待付款的tab页面
        if (orderType == 0) {
          this.filterOrderList(operactionInfo.goId);
        } else {
          // 不展示支付按钮,状态修改为待发货
          this.setOrderListAttribute(operactionInfo.goId, 'status', 1);
        }
      } else if (operactionInfo.operaction == 'payAward') {
        // 点击支付有礼
        this.setOrderListAttribute(operactionInfo.goId, 'payAward', null);
      }
    },
    // 设置订单的属性
    setOrderListAttribute(goId, name, value) {
      if (isFromOrderList) {
        let orderList = this.orderList;
        orderList.forEach((item, index) => {
          if (item.goId == goId) {
            this.$set(orderList[index], name, value)
          }
        })
        this.$store.commit('updateOrderList', orderList);
        isFromOrderList = false;
      } else if (isFromAllOrderList) {
        let allOrderList = this.allOrderList;
        allOrderList.forEach((item, index) => {
          if (item.goId == goId) {
            this.$set(allOrderList[index], name, value)
          }
        })
        this.$store.commit('updateAllOrderList', allOrderList);
        isFromAllOrderList = false;
      }
    },
    // 过滤订单
    filterOrderList (goId) {
      sessionStorage.setItem('filterOrder', true);
      if (isFromOrderList) {
        let orderList = this.orderList;
        let list = orderList.filter(item => item.goId != goId);
        this.$store.commit('updateOrderList', list);
        isFromOrderList = false;
      } else if (isFromAllOrderList) {
        let allOrderList = this.allOrderList;
        let list = allOrderList.filter(item => item.goId != goId);
        this.$store.commit('updateAllOrderList', list);
        isFromAllOrderList = false;
      }
    },
    handleClickSubmit() {
      if (this.awardInfo.prodType == this.ckFrom.course) {
        this.$routerGo(this, "replace", { path: "/member/myInterest/interestIndex" });
      } else {
        this.getShopInfo(this.awardInfo.prodId, this.palId)
      }
    },
    // 点击判断选择支付有礼奖品类型
    handleClickpayAward() {
      if (this.payAward != null) {
        this.receivePayAward(this.payAward);
      }
      if (isFromOrderList || isFromAllOrderList) {
        let operactionInfo = {
          goId: goId,
          operaction: 'payAward'
        }
        this.partUpateOrder(operactionInfo);
      }
    },
    // 获取优惠卷信息
    receivePayAward(payAward) {
      utilJs.postMethod(global.apiurl + `activity/payAward/receivePayAward`, {
        orderId: payAward.orderId,
        md5Key: payAward.md5Key,
        ppId: payAward.ppId,
        paId: payAward.paId
      }, res => {
        this.awardInfo = res.awardInfo;
        this.palId = res.palId;
        if (res.awardType == 1) {
          this.isPayAward = true;
          this.adCoupon = res.redeemDataList.filter(i => i.couponStatus == 0);
          this.isVoucher = res.redeemDataList.some(item => {
            if (item.couponSource == 2) {
              return true;
            }
          })
          this.adCoupon.forEach(ele => {
            ele.startAt = ele.startAt ? ele.startAt.split(' ')[0].replace(/-/g, '.') : ''
            ele.endAt = ele.endAt ? ele.endAt.split(' ')[0].replace(/-/g, '.') : ''
          })
          this.showCouponDialog = true;
          return;
        }
        if (res.awardType == 2) {
          this.giftModal = true;
        } else {
          // 活动
          let goPath = res.awardInfo.url.match(/#(\S*)/)[1];
          this.$routerGo(this, "push", {
            path: goPath
          });
        }
      }, failes => {
        window.location.reload();
      })
    },
    clickPayOrder() {
      if (this.balanceOrderInfo && this.balanceOrderInfo.finalBalanceOrderId && this.balanceOrderInfo.payMoney) {
        this.payMoney = this.balanceOrderInfo.payMoney;
        this.clickSubmitOrder();
        return
      }
      // 未开始支付尾款不能支付
      if (this.balanceOrderInfo && this.balanceOrderInfo.finalBalanceTimeStatus == 0) return
      this.getShopInfo(this.shopList[0].mgId)
    },
    getShopInfo(prodId, palId) {
      utilJs.getMethod(
        `${global.apiurl}goods/goodsDetail?mgId=${prodId}${palId ? '&palId=' + palId : ''}`,
        res => {
          this.shopInfo = res.goods;
          this.freeShipping = res.freeShipping;
          this.payAwardData = res.payAwardData;
          let shopInfo = [
            {
              mgId: this.shopInfo.mgId,
              mcId: "",
              avatar: this.shopInfo.avatar ? this.shopInfo.avatar : "",
              pointsDeduct: 0,
              name: this.shopInfo.name,
              price: this.payAwardData ? this.payAwardData.price : this.shopInfo.price,
              originalPrice: this.shopInfo.originalPrice,
              quantity: 1,
              shopSpecInfo: "",
              gsiiId: "",
              postage: this.shopInfo.postage,
              isMail: this.shopInfo.isMail,
              isMallExpressDeliver: this.shopInfo.isMallExpressDeliver,
              isMallOfflineDeliver: this.shopInfo.isMallOfflineDeliver,
              stock: 1,
              salesStock: "",
              collageStock: "",
              freeShipping: this.freeShipping,
              isFlashSales: false,
              isCollage: false,
              pId: "",
              noLimit: false,
              vipDiscount: this.shopInfo.vipDiscount,
              svipDiscount: this.shopInfo.svipDiscount,
              agentDiscount: this.shopInfo.agentDiscount,
              partnerDiscount: this.shopInfo.partnerDiscount,
              branchDiscount: this.shopInfo.branchDiscount,
              isPayAward: true,
              limitType: -1,
              limitNumber: 0,
              purchasedNum: 0,
              relData: this.shopInfo.relData && this.shopInfo.relData.length > 0 ? this.shopInfo.relData : [],
              vipDiscountType: this.shopInfo.vipDiscountType || 1
            }
          ];
          if (this.shopInfo.valuationMethod && this.shopInfo.valuationMethod == 2 && this.shopInfo.freightMode == 1) {
            shopInfo.valuationMethod = this.shopInfo.valuationMethod;
          }
          if (this.balanceOrderInfo) {
            shopInfo[0].isPayAward = false
            shopInfo[0].presale = this.balanceOrderInfo;
            shopInfo[0].moneyType = 3; // 预售尾款
            shopInfo[0].gsiiId = this.shopList[0].gsiiId;
            shopInfo[0].stock = this.shopList[0].quantity;
            shopInfo[0].quantity = this.shopList[0].quantity;
            shopInfo[0].minOrderQuantity = this.shopList[0].quantity;
            shopInfo[0].price = this.balanceOrderInfo.aPrice;
            shopInfo[0].enableDeduction = this.balanceOrderInfo.enableDeduction;
            shopInfo[0].pointsDeduct = this.shopInfo.pointsDeduct; //限时购不能使用积分
            shopInfo[0].shopSpecInfo = this.shopList[0].subSpecs;
            if (this.offline) {
              localStorage.setItem('mod', JSON.stringify(this.offline));
            }
          }
          sessionStorage.setItem("shopBuyInfo", JSON.stringify(shopInfo));
          let goPath = `/mall/shopSettlement/shopSettlement?shopNo=${prodId}${palId ? '&palId=' + palId : ''}${this.balanceOrderInfo ? '&goId=' + goId : ''}`;
          this.$routerGo(this, "push", {
            path: goPath
          });
        }
      );
    },
    // 修改地址
    handleClickAddress() {
      this.$routerGo(this, "push", {
        path: "/mall/mallOrder/orderAddress",
        query: ({
          goId: goId
        })
      });
    },
    // 延长收获
    clickDelayReceiveOrder() {
      let that = this;
      isTest = window.location.href.indexOf('http://kptest') > -1 || window.location.href.indexOf('https://kptest') > -1; // 正式平台用3天，测试平台用3分钟
      let judgeTime = isTest ? (60 * 3) : (24 * 60 * 60 * 3);
      if ((automaticRecipientTime - currentDate) <= judgeTime) {
        that.$cjConfirm({
          title: '延长收货时间', //
          titleCenter: true, //标题是否居中
          message: '收货时间已延长3天，头部的时间自动加上3天时间',
          messageCenter: true, //内容是否居中
          showMasker: true, //是否显示透明背景
          clickCloseModal: false, //是否点击透明背景关闭弹窗
          showCancelButton: false, //是否显示取消按钮
          cancelButtonText: '', //取消按钮文本
          confirmButtonText: '我知道了', //确认按钮文本
          onConfirm() {
            utilJs.getMethod(
              global.apiurl + "goodsOrders/delayReceiveOrder/" + goId, res => {
                countDownTime = countDownTime + judgeTime;
                that.formTime = that.timeToStr(countDownTime);
                that.buyerIsDelayReceive = 1;
              }
            )
          },
        })
      } else {
        that.$cjConfirm({
          title: '延长收货时间', //
          titleCenter: true, //标题是否居中
          message: '延长收货需距离结束时间3天才能申请哦~',
          messageCenter: true, //内容是否居中
          showMasker: true, //是否显示透明背景
          clickCloseModal: false, //是否点击透明背景关闭弹窗
          showCancelButton: false, //是否显示取消按钮
          cancelButtonText: '', //取消按钮文本
          confirmButtonText: '我知道了', //确认按钮文本
          onConfirm() {
          },
        })
      }
    },
    // 收货判断
    orderConfirmReceipt() {
      let that = this;
      that.$cjConfirm({
        title: '确认收货',
        titleCenter: true, //标题是否居中
        message: '',
        messageCenter: true, //内容是否居中
        showMasker: true, //是否显示透明背景
        clickCloseModal: false, //是否点击透明背景关闭弹窗
        showCancelButton: true, //是否显示取消按钮
        cancelButtonText: '取消', //取消按钮文本
        confirmButtonText: '确认', //确认按钮文本
        onConfirm() {
          that.clickConfirmReceipt();
        },
      })
    },
    // 确认收货
    clickConfirmReceipt() {
      utilJs.postMethod(
        global.apiurl + "goodsOrders/orderHandle", {
          status: 3,
          goId: goId
        }, res => {
          if (isFromOrderList || isFromAllOrderList) {
            let operactionInfo = {
              goId: goId,
              operaction: 'receiveOrder'
            }
            this.partUpateOrder(operactionInfo);
          }
          this.$showCjToast({
            text: '已收货',
            type: 'success',
          }).then(() => {
            window.location.reload();
          })
          this.status = 3;
        }
      )
    },
    // 评论操作
    goComments(commentStatus) {
      if (commentStatus == 2) {
        this.$routerGo(this, "push", {
          path: isFromOrderList ? '/mall/shopComments/addShopComment?orderType=' + orderType : '/mall/shopComments/addShopComment',
          query: ({
            goId: goId,
            type: 1 // 1添加订单评论
          })
        })
      } else if (commentStatus == 1) {
        this.$routerGo(this, "push", {
          path: '/mall/shopComments/shopCommentDetail',
          query: ({
            id: goId,
            type: 1 // 1查看订单评论详情
          })
        })
      }
    },
    // 跳转到高德地图显示间距
    getLocation() {
      let info = {
        address: this.offline.address,
        modName: this.offline.modName,
        lat: this.offline.lat,
        lng: this.offline.lng
      }
      localStorage.setItem('address', JSON.stringify(info))
      this.$routerGo(this, "push", {
        path: '/distanceAMap'
      })
    },
    finishCollage() {
      let $this = this;
      setTimeout(function () {
        $this.getOrderInfo()
      }, 500)
    },
    goInvite() {
      this.$routerGo(this, "push", {
        path: "/homePage/collage/collageDetail",
        query: { isMall: 1, orderId: goId }
      })
    },
    showAllTeam() {
      utilJs.getMethod(global.apiurl + 'mallCollage/getAllTeamPeople?collageId=' + this.collageInfo.collageId + "&groupId=" + this.collageInfo.groupId, res => {
        this.showAllMerber = true;
        this.allTeamList = res.teamList;
        // if (this.collageInfo.groupStatus == 1) {
        //   for (let i = 0; i < this.collageInfo.lastPeopleNum; i++) {
        //     this.allTeamList.push({ headimgurl: '', type: 2, nickname: '匿名用户' })
        //   }
        // }
      });
    },
    copyText(id) {
      utilJs.copyText(id);
    },
    timeControl() {
      let that = this;
      timeControl = setInterval(function () {
        currentDate++;
        countDownTime--;
        if (countDownTime <= 0) {
          if (that.status == 0) { // 时间到未付款状态改变未超时关闭状态
            that.status = -3;
          } else if (that.status == 2) { // 时间到待收货改为完成状态
            that.status = 3;
          }
          clearInterval(timeControl);
        }
        that.formTime = that.timeToStr(countDownTime);
      }, 1000);
    },
    timeToStr(timeSecond) {
      //将秒转化为天：时格式
      let day = 0;
      let hour = 0;
      let minute = 0;
      let second = 0;
      if (timeSecond >= 60) {
        minute = parseInt(timeSecond / 60);
        second = parseInt(timeSecond % 60);
        if (minute >= 60) {
          hour = parseInt(minute / 60);
          minute = parseInt(minute % 60);
        } if (hour >= 60) {
          day = parseInt(hour / 24);
          hour = parseInt(hour % 24);
        }
      } else {
        second = timeSecond;
      }
      hour = hour >= 10 ? hour : "0" + hour;
      minute = minute >= 10 ? minute : "0" + minute;
      second = second >= 10 ? second : "0" + second;
      if (this.status == 0) {
        if (hour > 0) {
          return hour + "时" + minute + "分";
        } else {
          return minute + "分" + second + "秒";
        }
      } else if (this.status == 2) {
        if (day > 0) {
          return day + "天" + hour + "时";
        } else {
          return minute + "分" + second + "秒";
        }
      }
    },
    clickGoShop(shopNo) {
      this.$routerGo(this, "push", {
        path: "/mall/shopDetail/shopDetail",
        query: { shopNo: shopNo }
      });
    },
    goAddressDetail() {
      this.$routerGo(this, "push", {
        path: '/mall/shippingAddress/addressList',
        query: {fromOrderDetail: 1, goId: goId}
      })
    },
    //获取订单页信息
    getOrderInfo() {
      let data = {
        goId: goId,
      };
      utilJs.postMethod(`${global.apiurl}goodsOrders/subOrderPage`, data,
        res => {
          this.companyAuth = JSON.parse(localStorage.getItem("companyAuth")) || null;
          this.favourablePrice = res.favourablePrice;
          this.deductedPoints = res.deductedPoints;
          this.deductedMoney = res.deductedMoney;
          this.cashBackAmount = res.cashBackAmount;
          this.deductedCouponMoney = res.deductedCouponMoney;
          this.isCanUseGiftCard = res.goods[0] && res.goods[0].type == 512 ? false : (res.isCanUseGiftCard || false);
          this.payCoinNum = res.payCoinNum;
          this.coinAmount = res.coinAmount;
          this.proportion = res.giftCardConfig && res.giftCardConfig.proportion ? res.giftCardConfig.proportion : 0; // 虚拟币兑换率
          this.giftCardPay = res.giftCardPay || 0; // 使用虚拟币
          this.payMoney = res.payMoney;
          this.filterMoney = `<div><span class="c-fs28">${res.payMoney.split(".")[0]}</span>.<span>${res.payMoney.split(".")[1]}</span></div>`;
          this.balance = res.user.balance * 1;
          this.vipType = res.user.vipType;
          this.status = res.status;
          this.state = res.state;
          this.postage = res.postage;
          this.enableRefund = res.enableRefund;
          this.isSendSomeGoods = res.isSendSomeGoods || 0
          this.commentStatus = res.commentStatus;
          this.payAward = res.payAward;
          this.orderDetail = res;
          this.payConf = res.payConf;
          this.balanceOrderInfo = res.balanceOrderInfo;
          let totalPrice = 0;
          let totalAmount = 0;
          let noSalesTotal = 0;
          this.marketStatus = res.marketStatus;
          this.isChainOrder = res.isChainOrder;
          this.chainDiscountMoney = res.chainDiscountMoney;
          this.isReorder = res.isReorder;
          for (let item of res.goods) {
            if (item.type == 2) {
              totalPrice += Number(item.amount);
            } else {
              totalPrice += (item.price * item.quantity);
              noSalesTotal += (item.price * item.quantity);
              totalAmount += Number(item.amount);
            }
            if (item.type == 2) { //订单中包含限时购商品
              this.hasFlash = true;
            }
          }
          if ((noSalesTotal - totalAmount - Number(res.deductedMoney) - res.deductedCouponMoney - Number(res.cashBackAmount)) > 0) {
            this.vipDisAmount = (noSalesTotal - totalAmount - Number(res.deductedMoney) - res.deductedCouponMoney - Number(res.cashBackAmount)).toFixed(2);
            this.hasVipDiscount = true;
          }
          this.goodsTotalPrice = (totalPrice * 1).toFixed(2);
          //获取默认地址
          this.addressInfo = {
            name: res.goods[0].userName,
            mobile: res.goods[0].userMobile,
            address: res.goods[0].userAddress,
          };
          this.shopList = res.goods || [];
          this.packageNum = res.packageNum ? res.packageNum : 0;
          this.isSplitPackage = res.isSplitPackage ? res.isSplitPackage : -1;
          if ((res.shipName != null && res.shipNo != null && this.isSplitPackage == -1) || (this.isSplitPackage == 1 && this.packageNum == 1)) {
            this.wayBill = {
              shipName: res.shipName,
              shipNo: res.shipNo
            }
          }
          this.deliverType = this.isSplitPackage == -1 ? res.goods[0].deliverType : res.deliverType;
          this.cashTitle = res.cashTitle;
          // 判断类型是否显示列表信息
          if (this.shopList[0] && (this.shopList[0].type == 16 || this.shopList[0].type == 32 || this.shopList[0].type == 1024 || this.shopList[0].type == 4096)) {
            this.isShopListType = false;
          }
          this.deliverNo = res.goods[0].deliverNo;
          this.offline = res.offline;
          this.traces = res.traces ? res.traces : null;
          currentDate = res.serverTime ? res.serverTime : 0;
          automaticCancelTime = res.automaticCancelTime ? res.automaticCancelTime : 0;
          automaticRecipientTime = res.automaticRecipientTime ? res.automaticRecipientTime : 0;
          this.buyerIsDelayReceive = res.buyerIsDelayReceive ? res.buyerIsDelayReceive : 0;
          this.fromApp = res.fromApp;
          if (this.status == 0) {
            if (automaticCancelTime - currentDate >= 0) {
              countDownTime = automaticCancelTime - currentDate;
              this.timeControl();
            } else {
              this.status = -3; // 超时关闭
            }
          } else if (this.status == 2) {
            if (this.fromApp && this.fromApp == 10) return
            if (this.shopList.filter(item => item.afterStatus == 1).length > 0) {
              this.formTime = '';
            }
            else if (automaticRecipientTime - currentDate >= 0) {
              countDownTime = automaticRecipientTime - currentDate;
              this.timeControl();
            } else {
              this.status = 3;
            }
          }
          if (this.$route.query.collageId && res.goods[0].collage) {
            this.collageInfo = res.goods[0].collage;
            // let hasPeople = this.collageInfo.teamList.length;
            // if (this.collageInfo.groupStatus == 1 && hasPeople < 5 && this.collageInfo.peopleNum >= 5) {
            //   for (let i = 0; i < 5 - hasPeople; i++) {
            //     this.collageInfo.teamList.push({ headimgurl: '', type: 2, nickname: '匿名用户' })
            //   }
            // }
          } else {
            this.collageInfo = "";
          }
          this.protocolInfo = res.protocolInfo && res.protocolInfo.length > 0 ? res.protocolInfo : null;
        }
      );
    },
    clickDelectOrder() {
      let that = this;
      that.$cjConfirm({
        title: '确定要删除该订单', //
        titleCenter: true, //标题是否居中
        message: '',
        messageCenter: true, //内容是否居中
        showMasker: true, //是否显示透明背景
        clickCloseModal: false, //是否点击透明背景关闭弹窗
        showCancelButton: true, //是否显示取消按钮
        cancelButtonText: '', //取消按钮文本
        confirmButtonText: '', //确认按钮文本
        onConfirm() {
          utilJs.getMethod(
            global.apiurl + "goodsOrders/deleteClosedOrder/" + goId, (res) => {
              if (isFromOrderList || isFromAllOrderList) {
                let operactionInfo = {
                  goId: goId,
                  operaction: 'deleteOrder'
                }
                that.partUpateOrder(operactionInfo);
              }
              that.$showCjToast({
                text: res.data,
                type: "success",
              });
              that.$router.back(-1);
            }
          )
        },
        onCancel() {
        },
      })
    },
    clickCancelOrder() {
      this.$cjConfirm({
        title: '提示',
        message: '确认取消该订单？',
        onConfirm:() => {
          this.confimCancel();
        }
      })
    },
    showCycletime(start, end) {
      let stArr = start.split(':');
      let enArr = end.split(':');
      return `${stArr[0]}:${stArr[1]}-${enArr[0]}:${enArr[1]}`
    },
    //操作订单
    confimCancel() {
      let that = this;
      if (isClick) {
        return;
      }
      isClick = true;
      utilJs.postMethod(
        global.apiurl + "goodsOrders/orderHandle",
        {
          status: -2,
          goId: goId
        },
        res => {
          isClick = false;
          if (isFromOrderList || isFromAllOrderList) {
            let operactionInfo = {
              goId: goId,
              operaction: 'cancelOrder'
            }
            this.partUpateOrder(operactionInfo);
          }
          this.$showCjToast({
            text: res,
            type: "success",
          }).then(() => {
            that.$router.go(-1);
          });
        },
        failRes => {
          isClick = false;
        }
      );
    },
    //提交订单
    clickSubmitOrder() {
      utilJs.getMethod(global.apiurl + 'mall/handleOrderBefore?orderId=' + goId, res => { //拼团待支付订单先查询是否还可以支付
        if (res.status == 1) {
          this.isShowPay = true;
        } else {
          this.$showCjToast({
            text: res.error,
            type: "warn",
          });
        }
      });
    },
    //点击支付
    clickPayType(payType) {
      if (payType == 1) {
        this.showPassword = true;
      } else if (payType == 2) {
        // 小程序环境不能跳充值页面
        if (this.$isWxApp() && this.payCoinNum > this.coinAmount) {
          return
        }
        if (this.payCoinNum > this.coinAmount) { // 选择虚拟币支付，且虚拟币余额不足，则跳到虚拟币充值页面
          let query = this.$route.query || {};
          query.isComeFrom = 'mallOrderDetail';
          sessionStorage.setItem('giftCardBack', JSON.stringify(query))
          this.$routerGo(this, "replace", { path: "/member/giftCard/rechargeCard" });
          return;
        }
        this.mallGiftCardPay(goId);
      } else if (payType == 3) { // 支付宝支付
        let data = {goId: goId};
        // 预售尾款再生成待支付订单，则不需要在进入订单结算计算价格
        if (this.balanceOrderInfo && this.balanceOrderInfo.finalBalanceOrderId && this.balanceOrderInfo.payMoney) {
          data.goId = this.balanceOrderInfo.finalBalanceOrderId
        }
        utilJs.postMethod( global.apiurl + "payment/alipayConf", data, (aliRes) => {
          this.$routerGo(this, "replace", { path: "/homePage/course/aliPayMiddlePage", query: {orderId: aliRes.orderNo} });
        });
      } else {
        //  pc浏览器购买弹窗
        if (!utilJs.isWeiXin() && !utilJs.isMobileUserAgent() && !utilJs.isIOSAppALL() && !utilJs.isAndroidApp()) {
          this.showPassword = false;
          let hurl = window.location.href;
          let qrUrl = qr.getQrUrl({ url: hurl, size: 120 });
          this.$cjConfirm({
            title: 'pc微信扫码支付',
            message:  `<img src="${qrUrl}" style="margin-top: 10px;" class="c-ww200 c-hh200 c-center"/><p style="margin-top: 10px;">请使用<span style="color: red">当前账号的微信扫码</span>支付</p>`,
            cancelButtonText:'取消支付',
            confirmButtonText:'支付完成',
          })
          return;
        }
        this.wechatPay();
      }
    },
    //选择微信支付
    wechatPay() {
      let u = navigator.userAgent;
      let isAndroid = u.indexOf('APPLogin') > -1; //android终端
      let isiOS = u.indexOf('IOSLogin') > -1 || u.indexOf('IOSNewLogin') > -1 || navigator.userAgent.indexOf("IOSNewApp") > -1; //ios终端
      if (isAndroid == true || isiOS == true) {
        let backUrl = window.location.href.split("#")[0] + "#/member/myOrder/allOrderList";
        let data = {orderId: goId};
        // 预售尾款再生成待支付订单，则不需要在进入订单结算计算价格
        if (this.balanceOrderInfo && this.balanceOrderInfo.finalBalanceOrderId && this.balanceOrderInfo.payMoney) {
          data.orderId = this.balanceOrderInfo.finalBalanceOrderId
        }
        utilJs.appPay(data, 0, 0, 0, 2, backUrl);
      } else {
        if (isWechatPaying) {
          return;
        }
        isWechatPaying = true;
        let data = {goId: goId};
        // 预售尾款再生成待支付订单，则不需要在进入订单结算计算价格
        if (this.balanceOrderInfo && this.balanceOrderInfo.finalBalanceOrderId && this.balanceOrderInfo.payMoney) {
          data.goId = this.balanceOrderInfo.finalBalanceOrderId
        }
        utilJs.wechatMallPay(data, res => {
          isWechatPaying = false;
          if (isFromOrderList || isFromAllOrderList) {
            let operactionInfo = {
              goId: goId,
              operaction: 'payOrder'
            }
            this.partUpateOrder(operactionInfo);
          }
          this.getGuideData();
        }, fres => {
          isWechatPaying = false;
        });
      }
    },
    // 选择虚拟币支付
    mallGiftCardPay(goId) {
      if (this._isPayGiftCard) return;
      this._isPayGiftCard = true;
      utilJs.postMethod(`${global.apiurl}payment/mallGiftCardPay`, { goId: goId }, (res) => {
        this._isPayGiftCard = false;
        this.$showCjToast({
          text: "支付成功",
          type: "success",
        }).then(() => {
          this.paySuccessCallBack();
        });
      }, () => {
        this._isPayGiftCard = false;
      });
    },
    hidePwd() {
      this.showPassword = false;
    },
    confirmPwd(pwd) {
      let _this = this;
      //余额支付
      let data = { goId: goId, payPwd: pwd }
      // 预售尾款再生成待支付订单，则不需要在进入订单结算计算价格
      if (_this.balanceOrderInfo && _this.balanceOrderInfo.finalBalanceOrderId && _this.balanceOrderInfo.payMoney) {
        data.goId = _this.balanceOrderInfo.finalBalanceOrderId
      }
      if (sessionStorage.getItem('promotedAccountId')) {
        data.promotedAccountId = sessionStorage.getItem('promotedAccountId')
      }
      utilJs.yueMallPay(data, res => {
        this.$showCjToast({
          text: "支付成功",
          type: "success",
        }).then(() => {
          if (isFromOrderList || isFromAllOrderList) {
            let operactionInfo = {
              goId: goId,
              operaction: 'payOrder'
            }
            _this.partUpateOrder(operactionInfo);
          }
          _this.getGuideData();
        });
      });
    },
    closePay: function () {
      this.isShowPay = false;
    },
    getGuideData() {
      let _this = this;
      if (_this.balanceOrderInfo && _this.balanceOrderInfo.finalBalanceStatus == 0 && _this.status == 0) {
        _this.paySuccessCallBack();
        return
      }
      utilJs.getMethod(global.apiurl + 'common/getGuideData?prodId=' + this.shopList[0].mgId + '&prodType=' + global.ckFrom.shopping, function (res) {
        _this.guideData = res;
        // 开启引导购买展示 || 该商品购买能赠送积分展示
        if (_this.guideData.isNeedShowPayPage == 1 || (_this.guideData.givenPoints && _this.guideData.givenPoints > 0)) {
          _this.$routerGo(_this, "replace", {
            path: '/homePage/payPolitely/payPolitely',
            query: {
              orderId: goId,
              prodType: global.ckFrom.shopping
            }
          })
        } else {
          _this.paySuccessCallBack();
        }
      },
        failRes => {
          _this.paySuccessCallBack();
        }
      );
    },
    paySuccessCallBack() {
      if (this.shopList[0].type == 1024) {
        sessionStorage.setItem('isGiftOrderPay', '1')
      }
      if (this.payType == 0) {
        // 微信支付
        this.$router.go(-1);
      } else {
        this.$routerGo(this, "push", {
          path: '/member/myOrder/allOrderList',
          query: ({goId: goId})
        });
      }
    },
    clickRefundType(type) {
      this.showRefundType = false;
      this.$routerGo(this, "push", {
        path: '/mall/mallOrder/applyRefund',
        query: ({godId: this.currentGodId, type: type})
      })
    },
    goApplyRefund(item) {
      // 退定金流程
      if (this.balanceOrderInfo && !item) {
        item = this.shopList && this.shopList.length > 0 ? this.shopList[0] : null;
        // 完成订单、待收货、多商品且整个订单且点击商品已发货
        if ((this.status == 3) || (this.status == 2) || (this.status == 1 && deliverStatus == 2 && this.shopList && (this.shopList.length != this.packageNum))) {
          this.currentGodId = item.godId;
          this.showRefundType = true;
        } else {
          this.$routerGo(this, "push", {
            path: '/mall/mallOrder/applyRefund',
            query: ({godId: item.godId, type: 1, refundReason: 13})
          })
        }
        return
      }
      let godId = item.godId, afterStatus = item.afterStatus, gorId = item.gorId, deliverStatus = item.deliverStatus;
      if (afterStatus == -1) {
        if (this.enableRefund == 0) {
          this.$showCjToast({
            text: this.marketStatus == 1 ? "拼图正在进行中，无法进行售后" : "当前退款商户号和支付的商户号不一致，无法退款",
            type: "warn",
          });
          return
        }
        // 完成订单、待收货、多商品且整个订单且点击商品已发货
        if ((this.status == 3) || (this.status == 2) || (this.status == 1 && deliverStatus == 2 && this.shopList && (this.shopList.length != this.packageNum))) {
          this.currentGodId = godId;
          this.showRefundType = true;
        } else {
          this.$routerGo(this, "push", {
            path: '/mall/mallOrder/applyRefund',
            query: ({godId: godId, type: 1, isCanUseGiftCard: (this.isCanUseGiftCard && this.giftCardPay > 0 ? 1 : 0)})
          })
        }
      } else if (afterStatus == 1 || afterStatus == 0) {
        this.$routerGo(this, "push", {
          path: '/mall/mallOrder/orderAfterSales',
          query: ({godId: godId, gorId: gorId})
        })
      }
    },
    //分享
    wechatShare: function () {
      let shareUrl =
        window.location.href.split("#")[0] +
        "#/?refereeId=" +
        localStorage.getItem("userId");
      utilJs.wechatConfig(shareUrl, "", "", "", function () { });
    },
    //手机端分享
    appShare: function () {
      var shareUrl =
        window.location.href.split("#")[0] +
        "#/?refereeId=" +
        localStorage.getItem("userId");
      utilJs.appShareTrue("", "", shareUrl, "");
    }
  },
  beforeRouteLeave(to, from, next) {
    this.$cjConfirm.hide();
    clearInterval(timeControl);
    next();
  },
  mounted() {
    setDocumentTitle("订单详情");// eslint-disable-line
    this.wechatShare();
    isClick = false;
    isWechatPaying = false;
    countDownTime = 0;
    this.showPassword = false;
    this.isShowPay = false;
    this.hasFlash = false;
    this.hasVipDiscount = false;
    this.vipDisAmount = 0;
    this.formTime = '';
    this.filterMoney = '';
    this.showAllMerber = false;
    this.isShopListType = true;
    this.wayBill = null;
    this.packageNum = 0;
    this.isSendSomeGoods = 0;
    this.traces = null;
    this.state = 0;
    this.enableRefund = 0;
    this.orderDetail = {};
    this.giftModal = false;
    this.currentGodId = '';
    this.showRefundType = false;
    this.marketStatus = null;
    this.balanceOrderInfo = null; // 预售订单信息
    this.showInvoice = false;
    this.isChainOrder = false;
    this.chainDiscountMoney = 0;
    this.isReorder = 0;
    orderType = this.$route.query.type;
    goId = this.$route.query.goId ? this.$route.query.goId : 0;
    if (!checkEnableModule(global.ckFrom.mall, this)) {
      return;
    }
    automaticCancelTime = 0;
    automaticRecipientTime = 0;
    this.getOrderInfo();
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->

<style scoped lang="less">
.giftDialog {
  position: relative;
  top: 50%;
  left: 50%;
  width: 15.9rem;
  height: 19.475rem;
  margin-top: -9.7375rem;
  transform: translateX(-50%);
  background: url("https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/payPolitely/giftDialog_bg.png") no-repeat center center;
  background-size: contain;
  .giftDialog_msg {
    top: 3.65rem;
    left: 50%;
    transform: translateX(-50%);
  }
  .giftDialog_img {
    top: 6.25rem;
    left: 50%;
    transform: translateX(-50%);
    overflow: hidden;
  }
  .giftDialog_name {
    top: 10.75rem;
    left: 50%;
    transform: translateX(-50%);
  }
  .giftDialog_btn {
    width: 10.5rem;
    height: 1.9rem;
    top: 14.1rem;
    left: 50%;
    transform: translateX(-50%);
    background: url("../../../assets/i/wap/payPolitely/giftDialog_btn.png") no-repeat center center;
    background-size: contain;
    color: #F95F40;
    font-size: .7rem;
  }
  .giftDialog_get {
    bottom: 2.2rem;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
  }
}
.masker-content {
  background-color: #fff;
  max-height: 7.85rem;
  height: 7.85rem;
  width: 100%;
}
.masker-content1 {
  background-color: #fff;
  max-height: 9rem;
  height: 9rem;
  width: 100%;
}
.c-bg-f4f7f9 {
  background-color: #f4f7f9;
}
.address {
  position: absolute;
  top: 2.4rem;
  left: 0.6rem;
  right: 0.6rem;
  box-shadow: 2px 6px 6px 0px rgba(91, 91, 91, 0.06);
}
.order-fotter {
  width: 100%;
  max-width: 16rem;
  border: 1px solid rgba(242, 242, 242, 1);
  box-shadow: 0px -6px 3px 0px rgba(132, 132, 132, 0.03);
  position: fixed;
  margin: 0 auto;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
}
.bgTop {
  background-image: url('../../../assets/i/orderBg.png');
  height: 100%;
  width: 100%;
  background-position: top center;
  background-repeat: no-repeat;
  padding: 0.85rem 0.6rem;
}
.c-ww112 {
  width: 2.8rem;
}
.c-fc-lorange {color: #FF300C;}
.tagBg {background-color: rgba(255,48,12,0.1);}

</style>
